<?php
/**
 * beimuaihui System
 * Copyright(c) 2011-2020 beimuaihui.
 * @license    http://www.gnu.org/licenses/gpl.html     This software Under GPL V3 License 
 * beimuaihui@gmail.com
 * http://code.google.com/p/beimuaihui/
 * $Id: CommentController.php 197 2011-02-18 12:45:33Z beimuaihui $
 */

require_once 'Zend/Controller/Action.php';

class Blog_CommentController extends Baogg_Controller_Action {
	public function init(){
		Zend_Loader::loadClass("Comment");
		$this->comment=new Comment();
	}
	public function articleAction(){
		$params=Baogg_Controller::getUrlParams();
		$this->view->data=array();
		if(isset($params['article_id'])){
			$article_id=(int)$params['article_id'];
			$this->view->data=$this->comment->getList(array("a.article_id=".$article_id));
		}
	}
	public function addAction() {
		$params=Baogg_Controller::getUrlParams();
		$form ['myForm'] = array ('action'=>BAOGG_BASE_URL."blog/comment/addsave/");
		$form ['myFld'] = array ('legend' => Translate::$add . " " . Translate::$comment, 'pid' => 'myForm' );
		$form ['comment_title'] = array ('class' => '', 'pid' => 'myFld' );
		$form ['comment_content'] = array ('tag'=>'textarea','dojoType'=>"dijit.Editor",'extraPlugins'=>'["|", "insertHorizontalRule"]','class' => '', 'pid' => 'myFld' );
		$form ['submit'] = array ('label' => false, 'type' => 'submit', 'pid' => 'myFld' );
		$form ['reset'] = array ('label' => false, 'type' => 'reset', 'plugin' => 'submit:3' );
		$form ['article_id'] = array ('label' => false, 'type' => 'hidden','value'=>$params['article_id'], 'plugin' => 'submit:3' );
		
		Zend_Loader::loadClass ( "Baogg_View_Form" );
		$form = new Baogg_View_Form ( $form );
		$this->view->form = $form;
	}
	public function addsaveAction() {
		$params=Baogg_Controller::getUrlParams();
		$this->view->flag=$this->comment->add($params);
	}
	public function lastestAction(){
		$this->view->data=$this->comment->getList(array(1),array("a.comment_id desc"),array("offset"=>0,"size"=>10));
	}
	public function navigatorAction() {
	
	}
	public function rightsAction() {
	
	}
	public function bodyAction() {
	
	}
}
